<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>登录</h1>
    用户名: <input type="text" class="inp">
    密  码: <input type="text" class="pwd">
    <button class="btn">登录</button>

    <script>
        let inp=document.querySelector('.inp')
        let pwd=document.querySelector('.pwd')
        let btn=document.querySelector('.btn')
        btn.onclick = function() {
            let data={
                inp:inp.value,
                pwd:pwd.value,
            }
            let xhr = new XMLHttpRequest()
            xhr.open('post', '/log',true)
            xhr.send(JSON.stringify(data))
            xhr.onreadystatechange = function() {
                if(xhr.readyState===4&&xhr.status===200){
                    console.log(xhr.responseText);
                    
                }
            }
        }
    </script>
</body>
</html>